﻿package mortal.game.view.copy.ChallengeCopy.newView
{
    import Message.DB.Tables.*;
    import Message.Public.*;
    import com.mui.controls.*;
    import com.mui.utils.*;
    import extend.language.*;
    import flash.events.*;
    import mortal.common.*;
    import mortal.common.global.*;
    import mortal.game.cache.*;
    import mortal.game.events.*;
    import mortal.game.manager.*;
    import mortal.game.manager.msgTip.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.resource.info.item.*;
    import mortal.game.view.common.*;
    import mortal.game.view.common.display.*;
    import mortal.game.view.common.item.*;
    import mortal.game.view.copy.ChallengeCopy.data.*;
    import mortal.game.view.vip.*;
    import mortal.mvc.core.*;

    public class ChallengeMagicTowerRender extends GCellRenderer
    {
        private var _pic:GImageBitmap;
        private var _passIcon:GImageBitmap;
        private var _itemName:GTextFiled;
        private var _rewardItem:BaseItem;
        private var _enterCopyBtn:GLoadingButton;
        private var _level:GImageBitmap;
        private var _combat:BitmapNumberText;
        private var _challengeData:ChallengeData;

        public function ChallengeMagicTowerRender()
        {
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._pic = UIFactory.gImageBitmap("", 4, 58, this);
            this.pushUIToDisposeVec(UIFactory.gImageBitmap(ImagesConst.challengeCopyNewTxt_13, 51, 21, this));
            this.pushUIToDisposeVec(UIFactory.gImageBitmap(ImagesConst.challengeCopyNewTxt_14, 61 + 43 - 88, 370 + 58, this));
            this._level = UIFactory.gImageBitmap("", 82, 19, this);
            this._combat = UIFactory.bitmapNumberText(92, 426, "GuideItemUseNum.png", 16, 20, -2, this);
            var _loc_1:* = GlobalStyle.textFormatBai.center();
            _loc_1.size = 15;
            this._itemName = UIFactory.gTextField("", 37, 278, 120, 30, this, _loc_1);
            this._rewardItem = UICompomentPool.getUICompoment(BaseItem);
            this._rewardItem.setItemStyle(ItemStyleConst.Big, ImagesConst.ShopItemBg, 6, 6);
            this._rewardItem.move(61, 298 + 25);
            this.addChild(this._rewardItem);
            this._enterCopyBtn = UIFactory.gLoadingButton(ResFileConst.EnterMagicTowerCopyBtn, 44, 458, 110, 44, this);
            this._enterCopyBtn.configEventListener(MouseEvent.CLICK, this.enterCopy);
            this._passIcon = UIFactory.gImageBitmap(ImagesConst.ShopMallHasBuyIcon, 62, 452, this);
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            this._pic.dispose(param1);
            this._pic = null;
            this._enterCopyBtn.dispose(param1);
            this._enterCopyBtn = null;
            this._rewardItem.dispose(param1);
            this._rewardItem = null;
            this._itemName.dispose(param1);
            this._itemName = null;
            this._level.dispose(param1);
            this._level = null;
            this._combat.dispose(param1);
            this._combat = null;
            this._passIcon.dispose(param1);
            this._passIcon = null;
            this._challengeData = null;
            super.disposeImpl(param1);
            return;
        }// end function

        private function enterCopy(event:MouseEvent) : void
        {
            if (int(Cache.instance.vip.getTVipConfigByType(EVipRecordType._EVipRecordTypeFuckDevilTower)))
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.ChallengCopyEnter, this._challengeData));
            }
            else
            {
                MsgManager.showRollTipsMsg(Language.getStringByParam(35113, VipUtil.getVipMinLevelByType(EVipRecordType._EVipRecordTypeFuckDevilTower)), MsgRollTipsType.msgRollTips3);
            }
            return;
        }// end function

        override public function set data(param1:Object) : void
        {
            super.data = param1;
            var _loc_2:* = param1.data;
            this._challengeData = Cache.instance.copy.challengCopy.getDataByTowerAndSection(_loc_2.tower, _loc_2.section);
            this._level.imgUrl = "ChallengeTowerLevel_" + _loc_2.level;
            this._pic.imgUrl = "ExpeditionIcon_" + _loc_2.tower + "T5S" + _loc_2.level + "L.png";
            this._combat.text = _loc_2.sugCombat.toString();
            var _loc_3:* = _loc_2.reward.split("&");
            var _loc_4:* = (_loc_3[0] as String).split("#");
            var _loc_5:* = new ItemData(int(_loc_4[0]));
            this._rewardItem.itemData = _loc_5;
            this._itemName.htmlText = _loc_5.itemInfo.htmlName;
            if (_loc_2.level - this._challengeData.passLevel == 1)
            {
                this._passIcon.visible = false;
                this._enterCopyBtn.visible = true;
                this._enterCopyBtn.filterEnabled = true;
            }
            else if (this._challengeData.passLevel >= _loc_2.level)
            {
                this._passIcon.visible = true;
                this._enterCopyBtn.visible = false;
            }
            else if (this._challengeData.passLevel < _loc_2.level)
            {
                this._passIcon.visible = false;
                this._enterCopyBtn.visible = true;
                this._enterCopyBtn.filterEnabled = false;
            }
            return;
        }// end function

    }
}
